package com.lagou.service;

import com.lagou.pojo.OrderDetail;
import com.lagou.repository.OrderRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.UUID;

/**
 * @author ys
 */
@Service
public class OrderService {

    @Autowired
    OrderRepository orderRepository;

    public Page<OrderDetail> findAll(Integer pageNo, Integer pageSize){
        Pageable pageable = PageRequest.of(pageNo,pageSize);

        Page<OrderDetail> all = orderRepository.findAll(pageable);
        return all;
    }

    public OrderDetail saveOrUpdate(OrderDetail order){
        order = orderRepository.save(order);
        return order;
    }

    public OrderDetail findByOrderCode(String orderCode){
        OrderDetail order = orderRepository.findByOrderCode(orderCode);
        return order;
    }







}
